package com.mango.ch11;

import org.apache.hadoop.io.WritableComparable;
import org.apache.hadoop.io.WritableComparator;

public class CompositeKeyGroupCompartot extends WritableComparator {
    //必须要写这个构造器 否则 会报错  hadoop不知道要怎么实例化 这个比较器
    public CompositeKeyGroupCompartot() {
        super(CompositeKey.class,true);
    }

    @Override
    public int compare(WritableComparable a, WritableComparable b) {
        CompositeKey c1 = (CompositeKey) a;
        CompositeKey c2 = (CompositeKey) b;
        //按交易ID分组
        return c1.getName().compareTo(c2.getName());
    }
}
